package o;

import android.content.Context;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.ForumCardBean;
import com.huawei.appgallery.forum.base.https.jgw.JGWTabDetailResponse;
import com.huawei.appgallery.forum.base.https.jgw.JGWTabInfo;
import com.huawei.appgallery.forum.section.bean.ForumNoticeCardBean;
import com.huawei.appgallery.forum.section.bean.ForumSectionEnterCardBean;
import com.huawei.appgallery.forum.section.bean.ForumSectionHeadCardBean;
import com.huawei.appgallery.forum.section.card.ForumNoticeCard;
import com.huawei.appgallery.forum.section.card.ForumSectionEnterCard;
import com.huawei.appgallery.forum.section.card.ForumSectionHeadCard;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.Layout;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class cay extends brv {
    private String ˊॱ = null;
    private String ˋ = null;
    protected Map<String, c> ˏ = new LinkedHashMap();
    private ForumSectionHeadCardBean ˏॱ;
    private List<JGWTabInfo> ॱ = new ArrayList();
    private List<String> ॱˊ = null;
    private Context ॱᐝ;

    public static class c {
        protected List<JsonBean> ˋ = new ArrayList();

        public c(List<CardBean> list) {
            ˊ(list);
        }

        protected void ˊ(List<CardBean> list) {
            ˋ(list);
        }

        public List<JsonBean> ˊ() {
            return this.ˋ;
        }

        public void ˋ(List<CardBean> list) {
            if (list != null) {
                this.ˋ.addAll(list);
            }
        }
    }

    public cay(Context context) {
        super(context);
        this.ॱᐝ = context;
    }

    public static boolean ˋ(cay o_cay, BaseRequest o_cvu, ResponseBean responseBean) {
        if (responseBean.getResponseCode() != 0) {
            return false;
        }
        JGWTabDetailResponse jGWTabDetailResponse = (JGWTabDetailResponse) responseBean;
        List<JGWTabInfo> ˎ = jGWTabDetailResponse.ˎ();
        if (ˎ != null) {
            o_cay.ॱ.clear();
            for (JGWTabInfo add : ˎ) {
                o_cay.ॱ.add(add);
            }
        }
        List<Layout> ʻॱ = jGWTabDetailResponse.ʻॱ();
        List<LayoutData> ᐝॱ = jGWTabDetailResponse.ᐝॱ();
        if (!(ʻॱ == null || ʻॱ.isEmpty())) {
            for (Layout layout : ʻॱ) {
                o_cay.ˏ(String.valueOf(layout.ˋ()), layout.ˎ(), null);
            }
        }
        if (!(ᐝॱ == null || ᐝॱ.isEmpty())) {
            for (LayoutData layoutData : ᐝॱ) {
                if (layoutData.ˋ() == null) {
                    bqx.ˋ("SectionDetailProvider", "layoutdata.datalist is null, layoutid:" + layoutData.ˎ());
                } else {
                    c ˊ = o_cay.ˊ(String.valueOf(layoutData.ˎ()));
                    if (ˊ != null) {
                        List<CardBean> ˋ = layoutData.ˋ();
                        if (ˋ != null) {
                            for (CardBean cardBean : ˋ) {
                                if (cardBean instanceof ForumCardBean) {
                                    ((ForumCardBean) cardBean).ˎ(jGWTabDetailResponse.ᐝ());
                                }
                            }
                            ˊ.ˋ(ˋ);
                        }
                    }
                }
            }
        }
        return true;
    }

    public c ˊ(String str) {
        return (c) this.ˏ.get(str);
    }

    public c ˏ(String str, String str2, List<CardBean> list) {
        ForumCard ˊ = cam.ˊ(str2, this.ॱᐝ);
        if (ˊ == null) {
            return null;
        }
        if (ˊ instanceof ForumSectionHeadCard) {
            this.ˋ = str;
        } else if (ˊ instanceof ForumNoticeCard) {
            if (this.ॱˊ == null) {
                this.ॱˊ = new ArrayList();
            }
            this.ॱˊ.add(str);
        } else if (ˊ instanceof ForumSectionEnterCard) {
            this.ˊॱ = str;
        }
        c cVar = new c(list);
        this.ˏ.put(str, cVar);
        return cVar;
    }

    public ForumSectionHeadCardBean ˊ() {
        if (this.ˏॱ != null) {
            return this.ˏॱ;
        }
        c cVar = (c) this.ˏ.get(this.ˋ);
        if (cVar == null) {
            return null;
        }
        List ˊ = cVar.ˊ();
        if (ˊ == null || ˊ.size() <= 0) {
            return null;
        }
        JsonBean jsonBean = (JsonBean) ˊ.get(0);
        if (!(jsonBean instanceof ForumSectionHeadCardBean)) {
            return null;
        }
        ForumSectionHeadCardBean forumSectionHeadCardBean = (ForumSectionHeadCardBean) jsonBean;
        this.ˏॱ = forumSectionHeadCardBean;
        return forumSectionHeadCardBean;
    }

    public ArrayList<ForumNoticeCardBean> ˎ() {
        ArrayList<ForumNoticeCardBean> arrayList = new ArrayList();
        if (this.ॱˊ != null) {
            for (String str : this.ॱˊ) {
                c cVar = (c) this.ˏ.get(str);
                if (cVar != null) {
                    List<JsonBean> ˊ = cVar.ˊ();
                    if (ˊ != null && ˊ.size() > 0) {
                        for (JsonBean jsonBean : ˊ) {
                            if (jsonBean instanceof ForumNoticeCardBean) {
                                ForumNoticeCardBean forumNoticeCardBean = (ForumNoticeCardBean) jsonBean;
                                forumNoticeCardBean.ˎ(true);
                                arrayList.add(forumNoticeCardBean);
                            }
                        }
                    }
                }
            }
        }
        return arrayList;
    }

    public ArrayList<JGWTabInfo> ˏ() {
        return (ArrayList) this.ॱ;
    }

    public ForumSectionEnterCardBean ˋ() {
        c cVar = (c) this.ˏ.get(this.ˊॱ);
        if (cVar == null) {
            return null;
        }
        List ˊ = cVar.ˊ();
        if (ˊ == null || ˊ.size() <= 0) {
            return null;
        }
        JsonBean jsonBean = (JsonBean) ˊ.get(0);
        return jsonBean instanceof ForumSectionEnterCardBean ? (ForumSectionEnterCardBean) jsonBean : null;
    }
}
